<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>破坏回文串</title>
</head>
<body>
  <script>
    function fn(nums) {
      let n = nums.length >> 1
      for (let i = 0; i < n; i++) {
        if (nums[i] !== 'a') return nums.replace(/[^a]/, 'a')
      }
      if (nums.length > 1) return nums.slice(0, -1) + 'b'
      return ''
    }
    console.log(fn('abccba'))
  </script>
</body>
</html>